class BookController < ApplicationController

  def index
    @all_books = Book.getAllBooks
    @popular_books = Book.getAllBooks
  end

  def show
    @book = Book.find(params[:id])
    @condition = Condition.find(@book.condition_id)
    @user = User.find(@book.user_id)
  end

  def new
    @conditions = Condition.find(:all)
  end

  def create
     @book = Book.new(params[:book])
    
    if @book.save
      flash[:notice] = 'Your book is ready to be traded'
      redirect_to :action => "index"
    else
      render :action => "new"
    end
  end

  def edit
  end

  def update
  end

  def destroy
  end

  def search
  end
end
